/**
 * 
 */
package com.softqin.washer.fragment;

import com.softqin.washer.R;
import com.softqin.washer.activity.MyAccountManageActivity;
import com.softqin.washer.activity.MyAddressActivity;
import com.softqin.washer.activity.MyCarActivity;
import com.softqin.washer.activity.MyInfoActivity;
import com.softqin.washer.activity.MyOrderActivity;
import com.softqin.washer.activity.MyOtherInfoActivity;
import com.softqin.washer.common.WasherApp;
import com.softqin.washer.utils.DialogUtils;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 * 
 * @ClassName: MyselfFragment
 * 
 * @Description: TODO(��(��������ҳ����ʾ))
 * 
 * @author ��ʢΰ
 * 
 * @date 2014-12-27 ����10:58:04
 */
public class MyselfFragment extends Fragment implements OnClickListener {

	private final static String TAG = "MyselfFragment";

	private View mView_myself;
	// �ж��Ƿ��Ѿ��������
	private boolean mIsLoad;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		mView_myself = inflater.inflate(R.layout.fragment_myself, container);
		initView(mView_myself);
		Log.i(TAG, "Myself");
		return mView_myself;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}

	private void initView(View v) {
		v.findViewById(R.id.myself_acount).setOnClickListener(this);
		v.findViewById(R.id.myself_car).setOnClickListener(this);
		v.findViewById(R.id.myself_info).setOnClickListener(this);
		v.findViewById(R.id.myself_address).setOnClickListener(this);
		v.findViewById(R.id.myself_order).setOnClickListener(this);
		v.findViewById(R.id.myself_other).setOnClickListener(this);
	}

	/**
	 * �ڴ���Fragment Hide and show ����ʱ����
	 */
	@Override
	public void onHiddenChanged(boolean hidden) {
		// TODO Auto-generated method stub
		super.onHiddenChanged(hidden);
		RelativeLayout llFragmenMyself = (RelativeLayout) mView_myself
				.findViewById(R.id.ll_fragment_myself);
		llFragmenMyself.setVisibility(View.VISIBLE);
		if(hidden && WasherApp.getInstance().mIHomepageBottomId != 3) {//���ص�ǰFragment
			Log.i(TAG,"MyselfFragment->this.isVisible():");
			mIsLoad = false;
		} else if (!mIsLoad) {
			// ��ʾ��ǰFragment,�����������
			Log.i(TAG, "��ʾ��ǰMyselfFragment,�����������");
			// ������
			mIsLoad = true;// �ڴ��ڲ�����ʵ��
		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.myself_acount:// �˻�����
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyAccountManageActivity.class));
			break;
		case R.id.myself_car:// �ҵĳ���
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyCarActivity.class));
			break;
		case R.id.myself_info:// �ҵ�����
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyInfoActivity.class));
			break;
		case R.id.myself_address:// �ҵĵ�ַ
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyAddressActivity.class));
			break;
		case R.id.myself_order:// �ҵĶ���
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyOrderActivity.class));
			break;
		case R.id.myself_other:// ������Ϣ
			startActivity(new Intent(MyselfFragment.this.getActivity(),
					MyOtherInfoActivity.class));
			break;

		default:
			break;
		}

	}

}
